<?php

/**
 * Created by Reliese Model.
 */

namespace App\Models\RandomCheck;

use Carbon\Carbon;
use App\Models\Projects\Product;
use App\Models\Eloquent;

/**
 * Class QtpRandomCheckModule
 *
 * @property int $id
 * @property int $product_id
 * @property string $name
 * @property string $remark
 * @property string $created_adminer
 * @property string $updated_adminer
 * @property string $adminer
 * @property Carbon|null $created_at
 * @property Carbon|null $updated_at
 *
 * @package App\Models
 */
class RandomCheckModule extends Eloquent
{
	protected $table = 'random_check_modules';

	protected $casts = [
		'product_id' => 'int'
	];

	protected $fillable = [
		'product_id',
		'name',
		'remark',
		'created_adminer',
		'updated_adminer',
		'adminer'
	];

    public static $fillables = [
        'product_id' => '产品.ID',
        'name' => '模块名称',
        'remark' => '模块说明',
        'created_adminer' => '创建人',
        'updated_adminer' => '更新人',
        'adminer' => '负责人',
    ];

    public function label()
    {
        $this->point_count = RandomCheckPoint::where('module_id', $this->id)->count();
        $this->product_name = Product::find($this->product_id)->name ?? '';
        return $this;
    }
}
